home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Games / Xconq 7.1.0 / src / xconq-7.1.0 / x11 / imf2x.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-07  |  2.4 KB  |  104 lines  |  [TEXT/R*ch]

  1. /* Convert the Xconq image format to X11 bitmaps and pixmaps.
  2.    Copyright (C) 1993, 1994, 1995 Stanley T. Shebs.
  3.  
  4. Xconq is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.  See the file COPYING.  */
  8.  
  9. #include "config.h"
  10. #include "misc.h"
  11. #include "lisp.h"
  12. #include "imf.h"
  13. #include "xutil.h"
  14.  
  15. #include <X11/Xos.h>
  16. #include <X11/Xlib.h>
  17. #include <X11/Xutil.h>
  18. #include <X11/Xresource.h>
  19.  
  20. extern int numimages;
  21.  
  22. extern ImageFamily **images;
  23.  
  24. extern char *outdirname;
  25.  
  26. char imdirname[1000];
  27.  
  28. int showprogress = 0;
  29.  
  30. void usage PARAMS ((void));
  31.  
  32. int
  33. main(argc, argv)
  34. int argc;
  35. char *argv[];
  36. {
  37.     int i, rslt;
  38.     char *arg;
  39.     FILE *ofp;
  40.  
  41.     init_lisp();
  42.  
  43.     if (argc == 1) usage();
  44.     for (i = 1; i < argc; ++i) {
  45.     arg = argv[i];
  46.     if (strcmp(arg, "-o") == 0) {
  47.         if (i + 1 < argc) {
  48.         outdirname = argv[i + 1];
  49.         /* Blast the arg because we'll be scanning the args again
  50.            and we want to ignore it then. */
  51.         argv[i] = NULL;
  52.         argv[i + 1] = NULL;
  53.         ++i;
  54.         } else {
  55.         init_error("No output directory following -o");
  56.         }
  57.     } else if (strcmp(arg, "-p") == 0) {
  58.         showprogress = 1;
  59.         argv[i] = NULL;
  60.     } else if (strcmp(arg, "--help") == 0) {
  61.         usage();
  62.         argv[i] = NULL;
  63.     }
  64.     }
  65.     /* We prefer a -o spec in order to do output, as a safety precaution;
  66.        one can always give "." as an argument so as to dump the bitmaps
  67.        into the current directory. */
  68.     if (outdirname == NULL)
  69.       init_warning("No output directory specified");
  70.     for (i = 1; i < argc; ++i) {
  71.     if (argv[i] != NULL) {
  72.         /* Interpret the arg as an imf file, open and read it. */
  73.         rslt = load_imf_file(argv[i], NULL);
  74.         if (!rslt)
  75.           run_warning("Couldn't open \"%s\", ignoring", argv[i]);
  76.     }
  77.     }
  78.     if (outdirname != NULL) {
  79.     /* Write the image directory file. */
  80.     sprintf(imdirname, "%s/%s", outdirname, "imf.dir");
  81.     ofp = fopen(imdirname, "w");
  82.     } else {
  83.     ofp = NULL;
  84.     }
  85.     for (i = 0; i < numimages; ++i) {
  86.     printf("/* %s imf */\n", images[i]->name);
  87.     if (ofp != NULL)
  88.       fprintf(ofp, "%s\n", images[i]->name);
  89.     write_x11_bitmaps(images[i], (ofp != NULL));
  90.     }
  91.     if (ofp != NULL) {
  92.     fclose(ofp);
  93.     }
  94.     return 0;
  95. }
  96.  
  97. void
  98. usage()
  99. {
  100.     fprintf(stderr,
  101.         "usage: imf2x [ files ... ] -o outdir [ files ... ] [ -p ]\n");
  102.     exit(1);
  103. }
  104.